# Contributor : zico <zico@dxx-rebirth.com>

pkgname=d1x-rebirth
pkgver=0.58.1
pkgrel=1
pkgdesc="An enhanced engine to play with Descent1 datas"
arch=('i686' 'x86_64')
url="http://www.dxx-rebirth.com/"
license=('custom:D1x' 'LGPL' 'custom:as-is')
depends=('sdl' 'sdl_mixer' 'mesa' 'physfs')
makedepends=('scons' 'unzip')
install="$pkgname.install"
patch1='le.patch'
source=(
"http://www.dxx-rebirth.com/download/dxx/${pkgname}_v${pkgver}-src.tar.gz"
"$pkgname.desktop"
"$pkgname.install"
"http://www.dxx-rebirth.com/download/dxx/res/d1xr-hires.dxa"
"http://www.dxx-rebirth.com/download/dxx/res/d1xr-sc55-music.dxa"
"$patch1"
)
noextract=(
"d1xr-hires.dxa"
"d1xr-sc55-music.dxa"
)

sha512sums=('d1bdaeee07c5ac34b2e6839fea1449344d206f76f1eb2ba3fd4fa7cbe6acd82c2e8d7140b2d6297add3d5e8fb7fe4ca2b1c22c900def94603c218f6660644c80'
            'd61b238e6c96a605267bd9d6981fcbcdbf150ac27a8d3bfbc2029e41e89b71e8e268ae0e5dc497ef0dcd055a00f3c96b21d3d24c05fa15d26e9c437bad5d9877'
            '079c75e3de5526ed8f74d7a57658b6e0a7254bc76630f1f7775fa5988c62fef489331c8d9cf7e5f1b32294df8046c164d518f8730eddca1b4ed521b6c26627d9'
            '3fc84d5610ba40ee383c1720f80513a21b4644ff8b6da4b84ebca13b11c1131deb4897ded6324b54845b6c847dfc0f16700535e16afdd7ebe83bfff042892302'
            '3cdce5b6535e28397b3216cc9ca05cccf7194349c62d64c54300f02f39248b98598d170599e5c61b6900d780e4917f905c3c31eb814fbb8429221c804cbd8bf9'
            '7783456a11101b60e008a7bf99c58e70d730534204fb9aa81674f9b7acb82d48c457ad71c7f224e7b5a06bdda826fc4ae0bfeb82f693a821650058ce662ed5ae')


prepare() {
  cd "$srcdir/${pkgname}_v${pkgver}-src"
  sed -ie "/^PREFIX =/s|/usr/local/|/usr/|" SConstruct

  patch -Np1 -i "../$patch1"
}

build() {
  cd "$srcdir/${pkgname}_v${pkgver}-src"
  scons sharepath="/usr/share/$pkgname" || return 1
}

package() {
  cd "$srcdir/${pkgname}_v${pkgver}-src"
  
  mkdir -p "$pkgdir/usr/bin/"
  mkdir -p "$pkgdir/usr/share/$pkgname/"
  mkdir -p "$pkgdir/usr/share/pixmaps/"
  mkdir -p "$pkgdir/usr/share/applications/"
  mkdir -p "$pkgdir/usr/share/licenses/$pkgname/"

  install -m755 "$pkgname" "$pkgdir/usr/bin/"
  cd "$srcdir/"
  install -m644 "$srcdir/${pkgname}_v${pkgver}-src/$pkgname.xpm" "$pkgdir/usr/share/pixmaps/"
  install -m644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/"
  install -m644 "$srcdir/${pkgname}_v${pkgver}-src/COPYING.txt" "$pkgdir/usr/share/licenses/$pkgname/"

  #due to pacman commit 2f7e92ad045fb276c8fe88d4793c8edc383d147c
  install -m644 "${SRCDEST}/d1xr-hires.dxa" "$pkgdir/usr/share/$pkgname/"
  install -m644 "${SRCDEST}/d1xr-sc55-music.dxa" "$pkgdir/usr/share/$pkgname/"
} 

